INIT_LIST_HEAD(&d->arch.extent_list);
+ d->arch.foreign_mfn_count = 1024;
+ d->arch.foreign_mfns = xmalloc_array(uint, d->arch.foreign_mfn_count);
+ BUG_ON(d->arch.foreign_mfns == NULL);
+
+ memset(d->arch.foreign_mfns, -1, d->arch.foreign_mfn_count * sizeof(uint));
+
return 0;
}
relinquish_memory(d, &d->xenpage_list);
relinquish_memory(d, &d->page_list);
free_extents(d);
+ xfree(d->arch.foreign_mfns);
return;
}
unimplemented();
}
+static ulong foreign_to_mfn(struct domain *d, ulong pfn)
+{
+
+ pfn -= 1UL << cpu_foreign_map_order();
+
+ BUG_ON(pfn >= d->arch.foreign_mfn_count);
+
+ return d->arch.foreign_mfns[pfn];
+}
+
+static int set_foreign(struct domain *d, ulong pfn, ulong mfn)
+{
+ pfn -= 1UL << cpu_foreign_map_order();
+
+ BUG_ON(pfn >= d->arch.foreign_mfn_count);
+ d->arch.foreign_mfns[pfn] = mfn;
+
+ return 0;
+}
+
static int create_grant_va_mapping(
unsigned long va, unsigned long frame, struct vcpu *v)
{
BUG();
return GNTST_permission_denied;
}
+ set_foreign(v->domain, va >> PAGE_SHIFT, frame);
return GNTST_okay;
}
BUG();
return GNTST_permission_denied;
}
+ set_foreign(d, addr >> PAGE_SHIFT, ~0UL);
return GNTST_okay;
}
/* quick tests first */
if (pfn & foreign_map_pfn) {
t = PFN_TYPE_FOREIGN;
- mfn = pfn & ~(foreign_map_pfn);
+ mfn = foreign_to_mfn(d, pfn);
} else if (pfn >= max_page && pfn < (max_page + NR_GRANT_FRAMES)) {
/* Its a grant table access */
t = PFN_TYPE_GNTTAB;
/* tell dom0 where ranted pages go in the linear map */
val[0] = cpu_foreign_map_order();
- val[1] = max_page;
+ val[1] = d->arch.foreign_mfn_count;
ofd_prop_add(m, n, "foreign-map", val, sizeof (val));
n = ofd_node_add(m, n, console, sizeof (console));
/* list of extents beyond RMA */
struct list_head extent_list;
+ uint foreign_mfn_count;
+ uint *foreign_mfns;
+
/* I/O-port access bitmap mask. */
u8 *iobmp_mask; /* Address of IO bitmap mask, or NULL. */